#include<stdio.h>

/*
 *
	1.txt  abvvvf

	current fp = 6
	After fseek fp = 2
	After fwrite fp = 5
	rewind fp = 0
	
	文件指针初始值是0
 *
 */

int main(){
	FILE * fp = fopen("1.txt", "w");
	if(fp == NULL){
		perror("fopen");
		return 0;
	}

	fwrite("abcdef", 6, 1, fp);
	printf("current fp = %ld\n", ftell(fp));

	fseek(fp, 2, SEEK_SET);
	printf("After fseek fp = %ld\n", ftell(fp));
	
	fwrite("vvv", 3, 1, fp);
	printf("After fwrite fp = %ld\n", ftell(fp));

	rewind(fp);
	printf("rewind fp = %ld\n", ftell(fp));


}

